<!DOCTYPE html>
<html lang="zh-cn">
<head>
	<meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="css/pintuer.css">
<link rel="stylesheet" href="css/admin.css">
<script src="js/jquery.js"></script>
<script src="js/pintuer.js"></script>
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>增加内容</strong></div>
  <div class="body-content">
    <form method="post"  id="form-x" class="form-x" action="/workview/superviseadd1">

		<div class="form-group">
			<div class="label">
				<label>成绩规则：</label>
			</div>
			<div class="field">
				<select name="performance_rule_id" id="performance_rule_id" class="input w50">
					<option selected="selected">请选择分类</option>
					<option value="1">1</option>
				</select>
				<span style="margin-left: 10px; color: red;">*</span>
				<div class="tips"> </div>
			</div>
		</div>

      <div class="form-group">
        <div class="label">
          <label>平时成绩：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="60" name="peacetime_performance" id="peacetime_performance" data-validate="required:请输入平时成绩" />
          <span style="margin-left: 10px; color: red;">*</span>
          <div class="tips"> </div>
        </div>
      </div>


	  <div class="form-group">
		   <div class="label">
		     <label>期中成绩：</label>
		   </div>
		   <div class="field">
		     <input type="text" class="input w50" value="60" name="mid_term_performance" id="mid_term_performance" data-validate="required:请输入期中成绩"/>
			   <span style="margin-left: 10px; color: red;">*</span>
		     <div class="tips"> </div>
		   </div>
	   </div>

		<div class="form-group">
			<div class="label">
				<label>期末成绩：</label>
			</div>
			<div class="field">
				<input type="text" class="input w50" value="60" name="final_performance" id="final_performance" data-validate="required:请输入期末成绩"/>
				<span style="margin-left: 10px; color: red;">*</span>
				<div class="tips"> </div>
			</div>
		</div>

	 <div class="form-group">
	   <div class="label">
	     <label>技能成绩：</label>
	   </div>
	   <div class="field">
	     <input type="text" class="input w50" value="60" name="skill_assessment" id="skill_assessment" data-validate="required:请输入技能成绩" />
		   <span style="margin-left: 10px; color: red;">*</span>
	     <div class="tips"> </div>
	   </div>
	 </div>

		<div class="form-group">
			<div class="label">
				<label>备注：</label>
			</div>
			<div class="field">
				<input type="text" class="input w50" value="60" name="remark" id="remark" data-validate="required:请输入备注" />
				<div class="tips"> </div>
			</div>
		</div>



		<div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-check-square-o" type="button" id="button bg-main icon-check-square-o" onclick="check1()"> 提交</button>
        </div>
      </div>
    </form>
  </div>
</div>

<script src="js/jquery.min.js"></script>
<script type="text/javascript">
	    function check1(){
            var  sno = localStorage.getItem("sno");
            var  elective_course_id = localStorage.getItem("ecid");
            var  tno = localStorage.getItem("supervisetno1");
            var  performance_rule_id=document.getElementById("performance_rule_id").value;
            var  peacetime_performance=document.getElementById("peacetime_performance").value;
            var  mid_term_performance=document.getElementById("mid_term_performance").value;
            var  final_performance=document.getElementById("final_performance").value;
            var  skill_assessment=document.getElementById("skill_assessment").value;
            var  total_score =peacetime_performance*0.2+mid_term_performance*0.2+final_performance*0.2+skill_assessment*0.4;
            var  pass_flag = 0;
            var  allow_flag = 0;
            var  remark=document.getElementById("remark").value;
            if (60<=total_score){
                pass_flag=1;
			}
			$.ajax({
            type:"POST",
            dataType:"json",
            url:"/workview/performanceadd",
	        data: ({
                sno: sno,
                elective_course_id: elective_course_id,
                tno: tno,
                performance_rule_id: performance_rule_id,
                peacetime_performance: peacetime_performance,
                mid_term_performance: mid_term_performance,
                final_performance: final_performance,
                skill_assessment: skill_assessment,
                total_score: total_score,
                pass_flag: pass_flag,
                allow_flag: allow_flag,
                remark: remark
            }),
	        success:function(data){
	                console.log(data);
	                if(data.status==401){
	                    alert("熔断开启，系统异常");
	                    window.location.href="login.html";
	                    return;
	                }
					if(data.status==2000) {
                        alert("重复添加");
						window.location.href="tstudent_electivelist.html";
						return;
					}
	                if(data.status==200) {
	                    localStorage.setItem("supervise",data.data);
	                    window.location.href="tstudent_electivelist.html";
	                    return;
	                }
	                if(data.status==500) {
	                    alert("添加失败");
	                    window.location.href="tstudent_electivelist.html";
	                    return;
	                }
	                 if(data.status==null) {
	                    alert("添加异常");
	                    window.location.href="tstudent_electivelist.html";
	                    return;
	                 }
	        },
	        error:function(XMLHttpRequest,textStatus) {
	            if (textStatus === 'timeout') {
	                alert('請求超時');
	                setTimeout(function () {
	                    alert('重新请求');
	                }, 2000);
	            }
	           // window.location.href="login.html";
                alert("系统异常ajax失败");
                window.location.href="tstudent_electivelist.html";
	        }
	
	    });
	
	}
	
	
</script>
</body>
</html>